package com.liang.pcc.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;

import java.util.concurrent.CountDownLatch;

/**
 * 自定义监听器，用于处理多线程读取 Excel 文件
 */
public abstract class BaseExcelListener<T> implements ReadListener<T> {

    protected final CountDownLatch latch;

    public BaseExcelListener(CountDownLatch latch) {
        this.latch = latch;
    }

    @Override
    public void invoke(T t, AnalysisContext analysisContext) {

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        latch.countDown();  // 关键点：通知当前 Sheet 处理完成
    }
}